package me.android.library.utils.android;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@UtilityClass
public class MarketUtil {

    /**
     * 跳转进市场
     */
    public void gotoAndroidMarket(Context cx) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.parse("market://details?id=" + cx.getPackageName());
        // Uri uri = Uri.parse("market://details?id=" + "com.tencent.mm");
        intent.setData(uri);
        cx.startActivity(intent);
    }

    /**
     * 跳转进市场并搜索
     */
    public void searchOnAndroidMarket(Context cx, String publisherName) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(String.format("market://search?q=pub:%s", publisherName)));
        cx.startActivity(intent);
    }
}
